go1.20.5
GoThrough

strings.Replace  1000

// Replace returns a copy of the string s with the first n // non-overlapping instances of old replaced by new. // If old is empty, it matches at the beginning of the string // and after each UTF-8 sequence, yielding up to k+1 replacements // for a k-rune string. // If n < 0, there is no limit on the number of replacements. func Replace(s string, old string, new string, n int) string

strings.ReplaceAll  843

// ReplaceAll returns a copy of the string s with all // non-overlapping instances of old replaced by new. // If old is empty, it matches at the beginning of the string // and after each UTF-8 sequence, yielding up to k+1 replacements // for a k-rune string. func ReplaceAll(s string, old string, new string) string

strings.NewReplacer  592

// NewReplacer returns a new Replacer from a list of old, new string // pairs. Replacements are performed in the order they appear in the // target string, without overlapping matches. The old string // comparisons are done in argument order. // // NewReplacer panics if given an odd number of arguments. func NewReplacer(oldnew ...string) *Replacer

strings.ToValidUTF8  85

// ToValidUTF8 returns a copy of the string s with each run of invalid UTF-8 byte sequences // replaced by the replacement string, which may be empty. func ToValidUTF8(s string, replacement string) string

strings.TrimSpace  24

// TrimSpace returns a slice of the string s, with all leading // and trailing white space removed, as defined by Unicode. func TrimSpace(s string) string

strings.Repeat  21

// Repeat returns a new string consisting of count copies of the string s. // // It panics if count is negative or if the result of (len(s) * count) // overflows. func Repeat(s string, count int) string

strings.Split  13

// Split slices s into all substrings separated by sep and returns a slice of // the substrings between those separators. // // If s does not contain sep and sep is not empty, Split returns a // slice of length 1 whose only element is s. // // If sep is empty, Split splits after each UTF-8 sequence. If both s // and sep are empty, Split returns an empty slice. // // It is equivalent to SplitN with a count of -1. // // To split around the first instance of a separator, see Cut. func Split(s string, sep string) []string

strings.SplitAfter  11

// SplitAfter slices s into all substrings after each instance of sep and // returns a slice of those substrings. // // If s does not contain sep and sep is not empty, SplitAfter returns // a slice of length 1 whose only element is s. // // If sep is empty, SplitAfter splits after each UTF-8 sequence. If // both s and sep are empty, SplitAfter returns an empty slice. // // It is equivalent to SplitAfterN with a count of -1. func SplitAfter(s string, sep string) []string

strings.SplitN  10

// SplitN slices s into substrings separated by sep and returns a slice of // the substrings between those separators. // // The count determines the number of substrings to return: // // n > 0: at most n substrings; the last substring will be the unsplit remainder. // n == 0: the result is nil (zero substrings) // n < 0: all substrings // // Edge cases for s and sep (for example, empty strings) are handled // as described in the documentation for Split. // // To split around the first instance of a separator, see Cut. func SplitN(s string, sep string, n int) []string

strings.Cut  8

// Cut slices s around the first instance of sep, // returning the text before and after sep. // The found result reports whether sep appears in s. // If sep does not appear in s, cut returns s, "", false. func Cut(s string, sep string) (before string, after string, found bool)

strings.Join  8

// Join concatenates the elements of its first argument to create a single string. The separator // string sep is placed between elements in the resulting string. func Join(elems []string, sep string) string

strings.SplitAfterN  7

// SplitAfterN slices s into substrings after each instance of sep and // returns a slice of those substrings. // // The count determines the number of substrings to return: // // n > 0: at most n substrings; the last substring will be the unsplit remainder. // n == 0: the result is nil (zero substrings) // n < 0: all substrings // // Edge cases for s and sep (for example, empty strings) are handled // as described in the documentation for SplitAfter. func SplitAfterN(s string, sep string, n int) []string

strings.LastIndex  6

// LastIndex returns the index of the last instance of substr in s, or -1 if substr is not present in s. func LastIndex(s string, substr string) int

regexp.MatchReader  5

// MatchReader reports whether the text returned by the RuneReader // contains any match of the regular expression pattern. // More complicated queries need to use Compile and the full Regexp interface. func MatchReader(pattern string, r io.RuneReader) (matched bool, err error)

strings.LastIndexAny  3

// LastIndexAny returns the index of the last instance of any Unicode code // point from chars in s, or -1 if no Unicode code point from chars is // present in s. func LastIndexAny(s string, chars string) int

strings.LastIndexByte  3

// LastIndexByte returns the index of the last instance of c in s, or -1 if c is not present in s. func LastIndexByte(s string, c byte) int

strings.LastIndexFunc  3

// LastIndexFunc returns the index into s of the last // Unicode code point satisfying f(c), or -1 if none do. func LastIndexFunc(s string, f func(rune) bool) int

strings.CutPrefix  3

// CutPrefix returns s without the provided leading prefix string // and reports whether it found the prefix. // If s doesn't start with prefix, CutPrefix returns s, false. // If prefix is the empty string, CutPrefix returns s, true. func CutPrefix(s string, prefix string) (after string, found bool)

strings.HasPrefix  3

// HasPrefix tests whether the string s begins with prefix. func HasPrefix(s string, prefix string) bool

regexp.CompilePOSIX  3

// CompilePOSIX is like Compile but restricts the regular expression // to POSIX ERE (egrep) syntax and changes the match semantics to // leftmost-longest. // // That is, when matching against text, the regexp returns a match that // begins as early as possible in the input (leftmost), and among those // it chooses a match that is as long as possible. // This so-called leftmost-longest matching is the same semantics // that early regular expression implementations used and that POSIX // specifies. // // However, there can be multiple leftmost-longest matches, with different // submatch choices, and here this package diverges from POSIX. // Among the possible leftmost-longest matches, this package chooses // the one that a backtracking search would have found first, while POSIX // specifies that the match be chosen to maximize the length of the first // subexpression, then the second, and so on from left to right. // The POSIX rule is computationally prohibitive and not even well-defined. // See https://swtch.com/~rsc/regexp/regexp2.html#posix for details. func CompilePOSIX(expr string) (*Regexp, error)

regexp.MustCompilePOSIX  3

// MustCompilePOSIX is like CompilePOSIX but panics if the expression cannot be parsed. // It simplifies safe initialization of global variables holding compiled regular // expressions. func MustCompilePOSIX(str string) *Regexp

strings.TrimPrefix  3

// TrimPrefix returns s without the provided leading prefix string. // If s doesn't start with prefix, s is returned unchanged. func TrimPrefix(s string, prefix string) string

regexp.Match  3

// Match reports whether the byte slice b // contains any match of the regular expression pattern. // More complicated queries need to use Compile and the full Regexp interface. func Match(pattern string, b []byte) (matched bool, err error)

regexp.MatchString  3

// MatchString reports whether the string s // contains any match of the regular expression pattern. // More complicated queries need to use Compile and the full Regexp interface. func MatchString(pattern string, s string) (matched bool, err error)

regexp.Compile  3

// Compile parses a regular expression and returns, if successful, // a Regexp object that can be used to match against text. // // When matching against text, the regexp returns a match that // begins as early as possible in the input (leftmost), and among those // it chooses the one that a backtracking search would have found first. // This so-called leftmost-first matching is the same semantics // that Perl, Python, and other implementations use, although this // package implements it without the expense of backtracking. // For POSIX leftmost-longest matching, see CompilePOSIX. func Compile(expr string) (*Regexp, error)

regexp.MustCompile  3

// MustCompile is like Compile but panics if the expression cannot be parsed. // It simplifies safe initialization of global variables holding compiled regular // expressions. func MustCompile(str string) *Regexp

regexp.QuoteMeta  3

// QuoteMeta returns a string that escapes all regular expression metacharacters // inside the argument text; the returned string is a regular expression matching // the literal text. func QuoteMeta(s string) string

strings.NewReader  2

// NewReader returns a new Reader reading from s. // It is similar to bytes.NewBufferString but more efficient and read-only. func NewReader(s string) *Reader

strings.Compare  1

// Compare returns an integer comparing two strings lexicographically. // The result will be 0 if a == b, -1 if a < b, and +1 if a > b. // // Compare is included only for symmetry with package bytes. // It is usually clearer and always faster to use the built-in // string comparison operators ==, <, >, and so on. func Compare(a string, b string) int

strings.CutSuffix  1

// CutSuffix returns s without the provided ending suffix string // and reports whether it found the suffix. // If s doesn't end with suffix, CutSuffix returns s, false. // If suffix is the empty string, CutSuffix returns s, true. func CutSuffix(s string, suffix string) (before string, found bool)